package com.atguigu.rabbitmq.two;

import com.atguigu.rabbitmq.util.RabbitmqUtil;
import com.rabbitmq.client.Channel;

import java.io.IOException;

/**
 * @author codingBee
 * @since 2021/6/22/20:51
 * 这是一个工作线程（相当于之前的消费者）
 */
public class Work01 {
    //队列名称
    public static final String QUEUE_NAME = "hello";
    //接收消息
    public static void main(String[] args) throws IOException {
        Channel chanel = RabbitmqUtil.getChannel();
        System.out.println("C3等待接收消息....");
        chanel.basicConsume(QUEUE_NAME,Boolean.TRUE,(consumerTag, message) -> {
            System.out.println(String.format("消息被接收 consumerTag:[%s]\tmessage:[%s]",consumerTag,new String(message.getBody())));
        },(consumerTag)->{
            System.out.println(String.format("消息被中断 consumerTag:[%s]",consumerTag));
        });
    }
}
